<template>
  <div class="mod-user">
    <!-- <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.userName" placeholder="用户名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form> -->
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        prop="id"
        header-align="center"
        align="center"
        width="80"
        label="ID">
      </el-table-column>
      <el-table-column
        prop="fullName"
        header-align="center"
        align="center"
        label="客户名称">
      </el-table-column>
      <el-table-column
        prop="phone"
        header-align="center"
        align="center"
        label="客户电话">
      </el-table-column>
      <el-table-column
        prop="demand"
        header-align="center"
        align="center"
        label="客户需求">
      </el-table-column>
      <el-table-column
        prop="budget"
        header-align="center"
        align="center"
        label="客户预算">
      </el-table-column>
      <el-table-column
        prop="ip"
        header-align="center"
        align="center"
        label="IP">
      </el-table-column>
      <el-table-column
        prop="ipHome"
        header-align="center"
        align="center"
        label="归属地">
      </el-table-column>
      <el-table-column
        prop="pathUrl"
        header-align="center"
        align="center"
        label="访问页面">
        <template slot-scope="scope">
          <a target="_blank" :href="scope.row.pathUrl" style="color: #f00;" v-if="scope.row.platform!='百度小程序'">{{ scope.row.pathUrl }}</a>
          <p v-else>{{ scope.row.pathUrl }}</p>
        </template>
      </el-table-column>
      <el-table-column
        prop="platform"
        header-align="center"
        align="center"
        label="来源平台">
      </el-table-column>
      <el-table-column
        prop="addTime"
        header-align="center"
        align="center"
        width="180"
        label="提交时间">
        <template slot-scope="scope">{{ $formatTime(scope.row.addTime, 'Y-m-d H:i:s') }}</template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        dataForm: {
          userName: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false
      }
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/api/v1/cms/messageBoard/queryCmsMessageBoardList'),
          method: 'POST',
          data: this.$http.adornParams({
            'pageNum': this.pageIndex,
            'pageSize': this.pageSize
          })
        }).then(({data}) => {
          if (data.data && data.code === 200) {
            this.dataList = data.data.list
            this.totalPage = data.data.total
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      }
    }
  }
</script>
